﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Threading;
using System.Reflection;
using Messaging2;
using u = FinPlusUtility.Utility;

namespace FinPlusQuoteRouter
{
    class Program
    {
        private static u.Config _config;
        private static u.Env _env;  

        static void Main(string[] args)
        {
            try
            {
                _config = u.ConfigXml(u.GetConfigPath(Assembly.GetExecutingAssembly()), out _env);

                var tran = new Transport(_config["messagingsettings"]["address"], int.Parse(_config["messagingsettings"]["port"]));
                var wait = int.Parse(_config["throttlesettings"]["waitmilliseconds"]);
                Console.WriteLine("Publishing live.");

                var t = new Thread(new Generate(tran, _env, _config, wait).Publish);
                t.Start();

                Console.WriteLine("Press <Enter> to stop.");
                Console.ReadLine();

                t.Abort();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.ReadLine();
            }
        }
    }

}
